package com.wxc.controller;

import com.wxc.entity.SysUser;
import com.wxc.exception.BusinessException;
import com.wxc.vo.REnum;
import com.wxc.vo.Resp;
import com.wxc.vo.req.TestReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author wxc
 * @date 2021年10月24日 10:26
 */
@RestController
@RequestMapping("/hello")
@Api("测试接口")
public class HelloController {

    @ApiOperation("测试")
    @GetMapping("/hello")
    public Resp<SysUser> hello() {
        SysUser sysUser = new SysUser();
        throw new BusinessException(REnum.BIND_ERROR);
        // return Resp.success(sysUser);
    }

    @ApiOperation("带参数的测试")
    @GetMapping("/hello2")
    public Resp<String> hello2(@RequestParam("name") String name) {
        return Resp.success(name);
    }

    @ApiOperation("测试JSR303")
    @PostMapping("/hello3")
    public Resp<TestReqVO> hello3(@Valid @RequestBody TestReqVO testReqVO) {
        return Resp.success(testReqVO);
    }
}
